package com.codelab.statemachine.config;

import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.guard.Guard;

public class ComplexFormCheckChoiceGuard implements Guard<ComplexFormStates, ComplexFormEvents> {
    @Override
    public boolean evaluate(StateContext<ComplexFormStates, ComplexFormEvents> stateContext) {
        boolean returnValue = false;
        Form form = stateContext.getMessage().getHeaders().get("form", Form.class);
        if(form.formName == null){
            returnValue = false;
        }else{
            returnValue = true;
        }

        return  returnValue;

    }
}
